package com.java8.dome1;

import com.alibaba.fastjson.JSON;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.OptionalInt;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static java.util.stream.Collectors.toList;

public class SteamTest {

    @Test
    public void test1(){
        String[] words = {"hello","world"};
        Stream<String[]> stream = Arrays.stream(words).map(w -> w.split(""));
        Stream<String> stringStream = stream.flatMap(Arrays::stream);
        System.out.println(JSON.toJSONString(stringStream.collect(toList())));
    }
    @Test
    public void test2(){
        OptionalInt reduce = IntStream.rangeClosed(0, 10).reduce(Integer::sum);
        reduce.ifPresent(System.out::println);
        int a,b,c;
        a=b=c=1;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println("789c");
    }
}
